package cn.tedu.micro.demo.device.controller;

import cn.tedu.micro.demo.common.protocol.JsonResult;
import cn.tedu.micro.demo.common.vo.GunInfoVO;
import cn.tedu.micro.demo.device.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 前后端分离的开发,如果不涉及到数据流的输出 比如文件(EXCEL WORD PDF)比如图片(png jpg jpeg)视频(mp4)
 * 一律按照@RestController处理
 */
@RestController
public class DeviceController {
    /**
     * 查询枪状态
     * path: /device/gun/info/{gunId}
     * method: GET
     * param: Integer gunId
     * return: JsonResult<GunInfoVO>
     * 控制层调用业务层的习惯: 控制层要什么 业务层就给我返回什么
     */
    @Autowired
    private DeviceService deviceService;
    @GetMapping("/device/gun/info/{gunId}")
    public JsonResult<GunInfoVO> checkGunStatus(@PathVariable(name = "gunId") Integer id){
        GunInfoVO vo=deviceService.checkGunStatus(id);
        return JsonResult.success(vo);//code=0 message="ok" 业务返回data=vo
    }
}
